//
//  vector4.h
//  GLDemo
//
//  Created by wneqi on 14-6-6.
//  Copyright (c) 2014年 xiewneqi. All rights reserved.
//

#ifndef __GLDemo__vector4__
#define __GLDemo__vector4__

#include "common_header.h"
#include <iostream>

class Vector4
{
public: // constructors and destructors
    Vector4 ();
    
    Vector4 (GLfloat x, GLfloat y);
    
    Vector4 (GLfloat x, GLfloat y, GLfloat z);
    
    Vector4 (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    
    ~Vector4 ();
    
public: // getters and setters
    GLfloat GetMagnitude () const;
    
    GLfloat GetSqrMagnitude () const;
    
    Vector4 GetNormalized () const;
    
    GLfloat GetX () const;
    
    void SetX (GLfloat x);
    
    GLfloat GetY () const;
    
    void SetY (GLfloat y);
    
    GLfloat GetZ () const;
    
    void SetZ (GLfloat z);
    
    GLfloat GetW () const;
    
    void SetW (GLfloat w);
    
public: // methods
    void Set (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    
public: // operators
    GLfloat& operator[] (int i);
    
    const GLfloat& operator[] (int i) const;
    
    Vector4 operator - () const;
    
    Vector4 operator + (Vector4 v) const;
    
    Vector4 operator - (Vector4 v) const;
    
    Vector4 operator * (GLfloat s) const;
    
    Vector4 operator / (GLfloat s) const;
    
    bool operator == (Vector4 v) const;
    
    bool operator != (Vector4 v) const;
    
    friend std::ostream& operator << (std::ostream& stream, const Vector4& v);
    
public: // static members
    static const Vector4 one;
    
    static const Vector4 zero;
    
public: // static methods
    static GLfloat Distance (Vector4 a, Vector4 b);
    
    static GLfloat Dot (Vector4 a, Vector4 b);
    
    static Vector4 Lerp (Vector4 from, Vector4 to, GLfloat t);
    
    static Vector4 Max (Vector4 a, Vector4 b);
    
    static Vector4 Min (Vector4 a, Vector4 b);
    
    static Vector4 MoveTowards (Vector4 current, Vector4 target, GLfloat maxDistanceDelta);
    
    static Vector4 Project (Vector4 a, Vector4 b);
    
    static Vector4 Scale (Vector4 a, Vector4 b);
    
private: // private members
    GLfloat m_x;
    GLfloat m_y;
    GLfloat m_z;
    GLfloat m_w;
};

#endif /* defined(__GLDemo__vector4__) */
